package 毕业旅行问题;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int N = 20;
    static int[][] f = new int[1 << N][N];
    static int[][] w = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                w[i][j] = in.nextInt();
            }
        }
        for (int i = 0; i < 1 << N; i++) {
            Arrays.fill(f[i], 0x3f3f3f3f);
        }
        f[1][0] = 0;
        for (int i = 1; i < 1 << n; i += 2) {
            for (int j = 0; j < n; j++) {
                if ((i >> j & 1) == 1) {
                    for (int k = 0; k < n; k++) {
                        if ((i - (1 << j) >> k & 1) == 1) {
                            f[i][j] = Math.min(f[i][j], f[i - (1 << j)][k] + w[k][j]);
                        }
                    }
                }
            }
        }
        int res = 0x3f3f3f3f;
        for (int i = 1; i < n; i++) {
            res = Math.min(res, f[(1 << n) - 1][i] + w[i][0]);
        }
        System.out.println(res);
    }
}
